var express = require('express');
var router = express.Router();
const userService = require("../src/services/userServices")
/* GET users listing. */
router.post('/login', async function (req, resp) {
  let {
    username,
    pwd
  } = req.body;
  let res = await userService.login(username, pwd);
  if (res) {
    resp.json({
      "code": 1,
      "msg": "登录成功"
    })
  } else {
    resp.json({
      "code": 0,
      "msg": "登录失败"
    })
  }
});
router.post('/reg', async function (req, resp) {
  let {
    username,
    pwd
  } = req.body;
  let res = await userService.register(username, pwd);
  if (res.code) {
    resp.json({
      "code": 1,
      "msg": res.msg
    })
  } else {
    resp.json({
      "code": 0,
      "msg": res.msg
    })
  }
});

module.exports = router;